<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="sealte.hvpms.pojo.Admin,sealte.hvpms.pojo.Message,sealte.hvpms.dao.impl.MessageDAOImpl" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>仓鼠网上投票系统HVPMS</title>
<link href="css/messages_add.jsp.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-1.4.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
function prevStep(){
	window.location.href='<%=basePath%>hvpms_admin/messages_management.jsp';
}
function validateToSubmit(){
	var title = $('#title').val();
	var content = $('#content').val();
	var mform = $('#messageForm');
	var reg = /^\s+|\s+$/g;
	title = title.replace(reg,"");
	content = content.replace(reg,"");
	if(title!=""){
		if(content!=""){
			mform.submit();
		}else{
			alert("消息内容不能为空！");
		}
	}else{
		alert("消息主题不能为空！");
	}
}
</script>
</head>
<body>
<%
	Admin admin = (Admin)session.getAttribute("admin");
	if(admin!=null){
		String id_str = (String)request.getParameter("id");
		int id = Integer.parseInt(id_str);
		Message mes = (new MessageDAOImpl()).getMessageByID(id);
%>
<div id="num2">
	<h2><img src="images/messages_view.png">&nbsp;系统消息管理--查看&nbsp;修改</h2>
</div>

<div id="num1">
<form action="AdminModifyMessage" method="POST" id="messageForm">
<table id="messageTable">
	<tr>
		<th>消息主题：</th>
		<td><input type="text" name="messageTitle" size="71" id="title" value="<%=mes.getTitle() %>"/></td>
	</tr>
	<tr>
		<th valign="top">消息内容：</th>
		<td><textarea cols="60" rows="15" name="messageContent" id="content"><%=mes.getContent() %></textarea></td>
	</tr>
	<tr>
		<td></td>
		<td align="left">
			<input type="button" value="提交修改" onclick="validateToSubmit()"/>
			<input type="button" value="返回" onclick="prevStep()"/>
		</td>
	</tr>
</table>
<input type="hidden" name="id" value="<%=mes.getId() %>"/>
</form>
</div>
	<span>
			<%
				String message_modify = (String)request.getAttribute("message_modify");
				if(message_modify!=null&&!"".equals(message_modify)){
					out.println("["+message_modify+"]");
				}
			%>
	</span>
<%	
	}else{
		out.println("谢绝跨路径访问！");
	}
%>
</body>
</html>